package com.example.kingdee.sqlTool.common;

import java.util.ArrayList;
import java.util.HashMap;

public class QueryResult {

    private String code;
    private String msg;
    private Long count;

    private HashMap<String,String> notes;
    private ArrayList<HashMap<String, Object>> records;
    private ArrayList<String> selectArray;

    public ArrayList<String> getSelectArray() {
        return selectArray;
    }

    public void setSelectArray(ArrayList<String> selectArray) {
        this.selectArray = selectArray;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Long getCount() {
        return count;
    }

    public void setCount(Long count) {
        this.count = count;
    }

    public ArrayList<HashMap<String, Object>> getRecords() {
        return records;
    }

    public void setRecords(ArrayList<HashMap<String, Object>> records) {
        this.records = records;
    }

    public HashMap<String, String> getNotes() {
        return notes;
    }

    public void setNotes(HashMap<String, String> notes) {
        this.notes = notes;
    }

    public void selectResultColumn(String... columnNames){
        for (HashMap<String, Object> record : getRecords()) {
            record.forEach((k,v)->{
                for (String columnName : columnNames) {
                    if(!columnName.contains(k)){
                        record.remove(k);
                    }
                }
            });
        }
    }
}
